std::filesystem::permissions(filename.toStdString(), defaultWritePermissions, std::filesystem::perm_options::add);
}
}
- catch (std::filesystem::filesystem_error e)
+ catch (const std::filesystem::filesystem_error &e)
{
qCWarning(lcFileSystem()) << filename << (readonly ? "readonly" : "read write") << e.what();
}
- catch (std::system_error e)
+ catch (const std::system_error &e)
{
qCWarning(lcFileSystem()) << filename << e.what();
}
setFileReadOnly(filename, readonly);
return true;
}
- catch (std::filesystem::filesystem_error e)
+ catch (const std::filesystem::filesystem_error &e)
{
qCWarning(lcFileSystem()) << filename << (readonly ? "readonly" : "read write") << e.what();
}
- catch (std::system_error e)
+ catch (const std::system_error &e)
{
qCWarning(lcFileSystem()) << filename << e.what();
}
const auto permissions = filePermissionsWin(filename);
return static_cast<bool>((permissions & std::filesystem::perms::owner_write));
}
- catch (std::filesystem::filesystem_error e)
+ catch (const std::filesystem::filesystem_error &e)
{
qCWarning(lcFileSystem()) << filename << e.what();
}
- catch (std::system_error e)
+ catch (const std::system_error &e)
{
qCWarning(lcFileSystem()) << filename << e.what();
}
const auto permissions = filePermissionsWin(filename);
return static_cast<bool>((permissions & std::filesystem::perms::owner_read));
}
- catch (std::filesystem::filesystem_error e)
+ catch (const std::filesystem::filesystem_error &e)
{
qCWarning(lcFileSystem()) << filename << e.what();
}
- catch (std::system_error e)
+ catch (const std::system_error &e)
{
qCWarning(lcFileSystem()) << filename << e.what();
}
{
static constexpr auto writePerms = std::filesystem::perms::owner_write | std::filesystem::perms::group_write | std::filesystem::perms::others_write;
const auto stdStrPath = path.toStdWString();
- try {
+ try
+ {
switch (permissions) {
case OCC::FileSystem::FolderPermissions::ReadOnly:
std::filesystem::permissions(stdStrPath, writePerms, std::filesystem::perm_options::remove);
case OCC::FileSystem::FolderPermissions::ReadWrite:
break;
}
- } catch (const std::filesystem::filesystem_error &e) {
+ }
+ catch (const std::filesystem::filesystem_error &e)
+ {
qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
return false;
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what();
+ return false;
+ }
+ catch (...)
+ {
+ qCWarning(lcFileSystem()) << "exception when modifying folder permissions";
+ return false;
+ }
#ifdef Q_OS_WIN
SECURITY_INFORMATION info = DACL_SECURITY_INFORMATION;
}
#endif
- try {
+ try
+ {
switch (permissions) {
case OCC::FileSystem::FolderPermissions::ReadOnly:
break;
std::filesystem::permissions(stdStrPath, std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
break;
}
- } catch (const std::filesystem::filesystem_error &e) {
+ }
+ catch (const std::filesystem::filesystem_error &e)
+ {
qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
return false;
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what();
+ return false;
+ }
+ catch (...)
+ {
+ qCWarning(lcFileSystem()) << "exception when modifying folder permissions";
+ return false;
+ }
return true;
}
bool FileSystem::isFolderReadOnly(const std::filesystem::path &path) noexcept
{
- try {
+ try
+ {
const auto folderStatus = std::filesystem::status(path);
const auto folderPermissions = folderStatus.permissions();
return (folderPermissions & std::filesystem::perms::owner_write) != std::filesystem::perms::owner_write;
qCWarning(lcFileSystem()) << "exception when checking folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
return false;
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcFileSystem()) << "exception when checking folder permissions" << e.what();
+ return false;
+ }
+ catch (...)
+ {
+ qCWarning(lcFileSystem()) << "exception when checking folder permissions";
+ return false;
+ }
}
FileSystem::FilePermissionsRestore::FilePermissionsRestore(const QString &path, FolderPermissions temporaryPermissions)
: _path(path)
{
- try {
+ try
+ {
const auto stdStrPath = _path.toStdWString();
_initialPermissions = FileSystem::isFolderReadOnly(stdStrPath) ? OCC::FileSystem::FolderPermissions::ReadOnly : OCC::FileSystem::FolderPermissions::ReadWrite;
if (_initialPermissions != temporaryPermissions) {
_rollbackNeeded = true;
FileSystem::setFolderPermissions(_path, temporaryPermissions);
}
- } catch (const std::filesystem::filesystem_error &e) {
+ }
+ catch (const std::filesystem::filesystem_error &e)
+ {
qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcFileSystem()) << "exception when modifying folder permissions";
+ }
}
FileSystem::FilePermissionsRestore::~FilePermissionsRestore()
_item->_status = SyncFileItem::NormalError;
_item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, e.what());
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcDirectory) << "exception when checking parent folder access rights" << e.what();
+ _item->_status = SyncFileItem::NormalError;
+ _item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, e.what());
+ }
+ catch (...)
+ {
+ qCWarning(lcDirectory) << "exception when checking parent folder access rights";
+ _item->_status = SyncFileItem::NormalError;
+ _item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, tr("unknown exception"));
+ }
} else {
try {
const auto permissionsChangeHelper = [] (const auto fileName)
_item->_status = SyncFileItem::NormalError;
_item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg(e.path1().c_str(), e.what());
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcDirectory) << "exception when checking parent folder access rights" << e.what();
+ _item->_status = SyncFileItem::NormalError;
+ _item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg("", e.what());
+ }
+ catch (...)
+ {
+ qCWarning(lcDirectory) << "exception when checking parent folder access rights";
+ _item->_status = SyncFileItem::NormalError;
+ _item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg("", tr("unknown exception"));
+ }
}
#endif
if (!_item->_isAnyCaseClashChild && !_item->_isAnyInvalidCharChild) {
{
qCWarning(lcPropagateDownload) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateDownload) << "exception when checking parent folder access rights" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateDownload) << "exception when checking parent folder access rights";
+ }
if (FileSystem::isFolderReadOnly(_parentPath)) {
FileSystem::setFolderPermissions(QString::fromStdWString(_parentPath.wstring()), FileSystem::FolderPermissions::ReadWrite);
FileSystem::setFilePermissionsWin(_tmpFile.fileName(), existingPermissions);
}
}
- catch (std::filesystem::filesystem_error e)
+ catch (const std::filesystem::filesystem_error &e)
{
qCWarning(lcPropagateDownload()) << _item->_instruction << _item->_file << e.what();
}
- catch (std::system_error e)
+ catch (const std::system_error &e)
{
qCWarning(lcPropagateDownload()) << _item->_instruction << _item->_file << e.what();
}
{
qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
+ }
#endif
emit propagator()->touchedFile(newDirStr);
done(SyncFileItem::NormalError, tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, e.what()), ErrorCategory::GenericError);
return;
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what();
+ done(SyncFileItem::NormalError, tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, e.what()), ErrorCategory::GenericError);
+ return;
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
+ done(SyncFileItem::NormalError, tr("The folder %1 cannot be made read-only: %2").arg(_item->_file, tr("unknown exception")), ErrorCategory::GenericError);
+ return;
+ }
}
try {
{
qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
+ }
#endif
// Insert the directory into the database. The correct etag will be set later,
{
qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights";
+ }
auto originParentFolderPath = std::filesystem::path{};
auto originParentFolderWasReadOnly = false;
{
qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights";
+ }
const auto restoreTargetPermissions = [this] (const auto &parentFolderPath) {
try {
{
qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what();
+ }
+ catch (...)
+ {
+ qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights";
+ }
};
const auto folderPermissionsHandler = FileSystem::FilePermissionsRestore{existingFile, FileSystem::FolderPermissions::ReadWrite};
{
qCritical() << e.what() << e.path1().c_str() << e.path2().c_str() << e.code().message().c_str();
}
+ catch (const std::system_error &e)
+ {
+ qCritical() << e.what() << e.code().message().c_str();
+ }
+ catch (...)
+ {
+ qCritical() << "exception unknown";
+ }
QTextCodec::setCodecForLocale(utf8Locale);
#endif
}